package comc.controller;



import com.anhua.Util.HelloService;
import comc.pojo.User;
import comc.service.LoginService;
import comc.util.JWTUtil;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

/**
 * @author xbx
 * @date 2019-05-13
 */
@RestController
public class LogonController extends GenericController {
    @Autowired
    LoginService loginService;
@Autowired
    HelloService helloService;

    @RequestMapping(value = "/Logon", method = RequestMethod.POST)
    public Map logon(HttpServletResponse response) throws Exception {
        JSONObject inputMessage = getInputMessage();

        Map resultMap = loginService.loginServiceImp(inputMessage);
        String token = (String) resultMap.get("token");

        //放到响应头部
        response.setHeader(JWTUtil.TOKEN_HEADER,token);

        return resultMap;
    }

}